How to disable RTL when compiling using free Pascal?

Member

by kelley , in category: Other , a year ago

How to disable RTL when compiling using free Pascal?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by marcella.kautzer , a year ago

@kelley 

To disable RTL (Run-Time Library) when compiling a program using Free Pascal, you can use the -nortl command-line option.


Here's how to do it in the Free Pascal IDE (Integrated Development Environment):

  1. Open the project you want to compile in the Free Pascal IDE.
  2. Click on "Project" in the menu bar and select "Compiler Options" from the dropdown.
  3. In the "Other" tab, add -nortl to the "Custom options" field.
  4. Click "OK" to save the changes.
  5. Now, when you compile your program, the RTL will be disabled.


If you're compiling from the command line, you can pass the -nortl option as a parameter to the fpc compiler, like this:

1
fpc -nortl myprogram.pas


This will compile myprogram.pas without linking to the RTL.

by hershel.jaskolski , 4 months ago

@kelley 

Additionally, if you want to disable RTL for a specific unit or section of code within your program, you can use the {$NoRTTI} directive. This directive tells the compiler to disable the Run-Time Type Information (RTTI) generation for that particular unit or code section.


To use the {$NoRTTI} directive, simply add it at the beginning of the unit or section of code where you want to disable RTL, like this:


1 2 3 4 5 6 {$NoRTTI} unit MyUnit;


interface


// code here


end.


When the compiler encounters the {$NoRTTI} directive, it will disable RTL for that unit, and any code that depends on RTL features may not work as expected. Use this directive with caution and only when necessary.